package com.itheima.exerciseTest.test60_69;

import java.util.concurrent.*;

public class Test63 {
    public static void main(String[] args) {
        // 创建线程池对象 ThreadPoolExecutor
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5,10,1, TimeUnit.SECONDS,new ArrayBlockingQueue<>(10), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());

        // 添加任务
        try {
            for (int i = 0; i < 21; i++) {
                threadPoolExecutor.submit(()->{
                    System.out.println(Thread.currentThread().getName() + "正在执行");
                });
            }
        } catch (RejectedExecutionException e) {
            System.out.println("排队多了");
        }


        // 关闭线程池
        threadPoolExecutor.shutdown();
    }
}
